// 对象：【无需的】属性和方法的集合
/* const arr = {
  22: 'a',
  24: 'b',
  7: 'c',
  a: 'b',
  xxxx: 'yyy',
}
console.log(Object.keys(arr)) */

// https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Object/keys

// https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Statements/for...in#%E4%BB%85%E8%BF%AD%E4%BB%A3%E8%87%AA%E8%BA%AB%E7%9A%84%E5%B1%9E%E6%80%A7

// https://stackoverflow.com/questions/5525795/does-javascript-guarantee-object-property-order

// 展开
/* const arr = ['a', 'b', 'c']
const tempArr = [...arr] // ...arr => 'a', 'b', 'c' => ['a', 'b', 'c']
console.log(tempArr) */

// “组合”、"收集"、"剩余"
// 求所有实参的集合
/* const fn = (...args) => {
  // 箭头函数没有 arguments 了
  console.log(args)
  console.log(args.reduce((acc, cur) => acc + cur))
}
fn(1, 2, 3)
fn(1, 2, 3, 4) */

const obj = { name: 'xxx', color: 'pink', age: 18, sex: 'man', address: '河南' }

// 冒号代表重命名，把 age 改成了 tempAge
// 等号代表默认值
const { color = 'red', name, age: tempAge, ...tempObj } = obj
console.log(name) // 'xxx'
console.log(tempAge) // 18
// console.log(age)
console.log(tempObj) // { sex: 'man', address: '河南' }
console.log(color) // 'red'

// Symbol
const obj2 = {
  name: 'xxx',
  color: 'pink',
  age: 18,
  sex: 'man',
  address: '河南',
}

// 往后端返回的这个对象里面加一个自己的属性
// obj2.height = '170cm' // 有可能会把之前对象里面本来的 height 覆盖掉
const hei = Symbol('身高')
obj2[hei] = '170cm'
console.log(obj2[hei])
